package org.edu.modules.kwgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.edu.modules.kwgl.entity.VeJwBkJiankao;
import org.edu.modules.kwgl.entity.VeJwKsJiankao;
import org.edu.modules.kwgl.mapper.VeJwKsJiankaoMapper;
import org.edu.modules.kwgl.service.IVeJwKsJiankaoService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: ve_jw_ks_jiankao
 * @Author: jeecg-boot
 * @Date:   2021-05-12
 * @Version: V1.0
 */
@Service
public class VeJwKsJiankaoServiceImpl extends ServiceImpl<VeJwKsJiankaoMapper, VeJwKsJiankao> implements IVeJwKsJiankaoService {

    @Override
    public List<String> get2teacheridByKsid(int ksid) {
        VeJwKsJiankao jiankao=baseMapper.selectOne(new QueryWrapper<VeJwKsJiankao>()
                .eq("type",1)
                .eq("ksid",ksid).last(" limit 1 ").orderByDesc("id"));
        VeJwKsJiankao xunkao=baseMapper.selectOne(new QueryWrapper<VeJwKsJiankao>()
                .eq("type",2)
                .eq("ksid",ksid).last(" limit 1 ").orderByDesc("id"));

        List<String> list=new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao.getTeacherid().toString());
        }else{
            list.add("暂未安排");
        }
        if(xunkao!=null){
            list.add(xunkao.getTeacherid().toString());
        }else{
            list.add("暂未安排");
        }
        return list;
    }

    @Override
    public List<VeJwKsJiankao> get2teacherByKsid(int bkid) {
        VeJwKsJiankao jiankao = baseMapper.selectOne(new QueryWrapper<VeJwKsJiankao>()
                .eq("ksid", bkid)
                .eq("type", 1).last(" limit 1 ").orderByDesc("id"));

        VeJwKsJiankao xunkao = baseMapper.selectOne(new QueryWrapper<VeJwKsJiankao>()
                .eq("ksid", bkid)
                .eq("type", 2).last(" limit 1 ").orderByDesc("id"));

        List<VeJwKsJiankao> list = new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao);
        }else{
            list.add(null);
        }
        if(xunkao!=null){
            list.add(xunkao);
        }else {
            list.add(null);
        }
        return list;
    }
}
